/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package org.abc;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * <p>Project: jse2303 - Format1
 * <p>Powered by webrx On @date 2023-07-10
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Format2 {
    public static void main(String[] args) {
        //格式化数字
        System.out.printf("%02d  %<02X %03.2f", 255, 255f);
        System.out.println();
        System.out.printf("%,d%n", Integer.MAX_VALUE);

        //格式化数字工具类
        //NumberFormat
        NumberFormat nf1 = NumberFormat.getPercentInstance(); //百分比效果
        System.out.println(nf1.format(.5));
        System.out.println(nf1.format(.05));
        System.out.println(nf1.format(1.2));

        var nf2 = NumberFormat.getCurrencyInstance(Locale.JAPAN);
        System.out.println(nf2.format(24234256));

        var nf3 = NumberFormat.getCurrencyInstance();
        nf3.setMinimumFractionDigits(5);
        nf3.setMinimumIntegerDigits(16);
        System.out.println(nf3.format(24234256));

        var nf4 = NumberFormat.getInstance();
        nf4.setMinimumFractionDigits(4);
        System.out.println(nf4.format(Integer.MAX_VALUE));
    }
}
